home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / dp_srccs / f-plasma.asm < prev    next >
Encoding:
Assembly Source File  |  1996-12-08  |  10.6 KB  |  460 lines

  1. ────────────────────────────────────────────────────────────────────────────────
  2. ; plasmoid/deep/thc 1996:
  3. ; code by plasmoid/deep/thc
  4. ────────────────────────────────────────────────────────────────────────────────
  5. vsync        macro
  6.              local    @@vs1, @@vs2
  7.         mov    dx,03dah    ; ∙ retrace sync...
  8. @@vs1:        in    al,dx
  9.         test    al,8
  10.         jnz    @@vs1        ; ∙ while not in display do.
  11. @@vs2:        in    al,dx
  12.         test    al,8
  13.         jz    @@vs2        ; ∙ while in display do
  14. endm
  15. ────────────────────────────────────────────────────────────────────────────────
  16. .model small
  17. .stack 400
  18. .code
  19. .386
  20.         locals
  21. scrwidth     equ     80
  22. initheight    equ    00
  23. vgaseg        equ    0a000h
  24. ────────────────────────────────────────────────────────────────────────────────
  25. .startup
  26. c_site:        jmp    main
  27. info        db    "∙ code by plasmoid of deep ∙"
  28. ────────────────────────────────────────────────────────────────────────────────
  29. realplasma      proc
  30.         mov     y,0
  31.         inc     counti
  32.         inc     od
  33.         sub     c,6                    ; ∙ normally 2!
  34.         mov     al,od
  35.         mov     d,al
  36.  
  37. @real2:         mov     al,y                    ; ∙ y loop
  38.         mov     bx,ax
  39.         shl     ax,8                    ; ∙ mul bx sucks...
  40.         shl     bx,6                    ; ∙ shifting rules!
  41.         add     ax,bx
  42.  
  43.         mov     bx,ax
  44.         mov     al,y
  45.         xor     ah,ah
  46.         and     al,1
  47.         add     ax,bx
  48.         mov     scroff,ax
  49.  
  50.         mov     al,counti
  51.         xor     ah,ah
  52.         and     al,1
  53.         xor     ah,ah
  54.         mov     bx,ax
  55.         shl     ax,8                    ; ∙ mul bx sucks...
  56.         shl     bx,6                    ; ∙ shifting rules!
  57.         add     ax,bx
  58.  
  59.         mov     bx,scroff
  60.         sub     bx,ax                   ; ∙ sub k
  61.         mov     scroff,bx
  62.  
  63.         mov     al,c
  64.         add     al,y
  65.         and     ax,255
  66.         mov     di,ax
  67.         mov     al,sint[di]              ; ∙ sin((c+y) and 255)
  68.         mov     a,al
  69.  
  70.         mov     al,d
  71.         and     al,255
  72.         mov     di,ax
  73.         mov     al,sint[di]              ; ∙ sin(d and 255)
  74.         mov     b,al
  75.         add     d,6
  76.  
  77.         xor     ax,ax
  78.         xor     bx,bx
  79.         mov     cx,256/2                ; ∙ length of plasma
  80.  
  81. @real1:         mov     al,a
  82.         add     al,b
  83.         mov     di,ax
  84.         mov     al,ft[di]               ; ∙ ft[a+b]
  85.         mov     bx,ax                   ; ∙ store value
  86.         inc     bx
  87.         mov     al,y
  88.         add     al,b
  89.         mov     di,ax
  90.         mov     al,ft[di]               ; ∙ ft[y+b]
  91.         add     ax,bx                   ; ∙ get stored value
  92.         shr     ax,3
  93.         inc     al
  94.         mov     color,al
  95.  
  96.         mov     di,scroff               ; ∙ screenoffset
  97.  
  98.         push    di
  99.         push    ax
  100.         push    cx
  101.         mov    cx,di
  102.         mov     al,04                   ; ∙ read mask
  103.         mov     ah,cl                   ; ∙ x position
  104.         and     ah,3
  105.         mov     dx,3ceh
  106.         out     dx,ax
  107.         shr    di,2
  108.         mov     al,es:[di+8+57*80]
  109.         cmp     al,00h                  ; ∙ color above starz?
  110.         je      noplot
  111.         pop    cx
  112.         pop    ax
  113.         pop    di
  114.  
  115. plot:         push    ax
  116.         push    cx
  117.         mov    cx,di
  118.           mov     ax,0102h
  119.         and     cl,03
  120.         shl     ah,cl
  121.         mov     dx,3c4h
  122.         out     dx,ax
  123.         pop    cx
  124.         pop    ax
  125.         shr    di,2
  126.         add    al,00
  127.             mov     es:[di+8+57*80],al              ; ∙ put pixel
  128.         jmp    cont
  129.  
  130. noplot:     pop    cx
  131.         pop    ax
  132.         pop    di
  133. cont:            mov     ax,scroff
  134.         add     ax,2
  135.         mov     scroff,ax
  136.  
  137.         xor     ah,ah
  138.         mov     al,color
  139.         shr     al,7                    ; ∙inc (a,1+color shr 7)
  140.         inc     al
  141.         xor     ah,ah
  142.         add    b,6
  143.         mov     bl,al
  144.         add     a,bl
  145.  
  146.         loop    @real9
  147.         jmp    @unreal
  148. @real9:        jmp    @real1
  149. @unreal:    inc     y
  150.         cmp     y,84
  151.         jne     @real2
  152.         ret
  153.  
  154. counti          db      000h
  155. a               db      000h
  156. b               db      000h
  157. c               db      000h
  158. d               db      000h
  159. od              db      000h
  160. color           db      000h
  161. y               db      000h
  162. scroff          dw      000h
  163. realplasma      endp
  164. ────────────────────────────────────────────────────────────────────────────────
  165. putlogo        proc    near
  166.         mov    si,offset vgalogo
  167.         mov    di,0
  168.         mov    bx,85
  169. @outer:        mov    cx,256
  170. @inner:        mov    al,[si]
  171.         push    di
  172.         push    ax
  173.         push    cx
  174.         mov    cx,di
  175.           mov     ax,0102h
  176.         and     cl,03
  177.         shl     ah,cl
  178.         mov     dx,3c4h
  179.         out     dx,ax
  180.         pop    cx
  181.         pop    ax
  182.         shr    di,2
  183.         mov    es:[di+8+57*80],al
  184.         pop    di
  185.         inc    di
  186.         inc    si
  187.         loop    @inner
  188.         add    di,320-256
  189.         dec    bx
  190.         jnz    @outer
  191.         ret
  192. putlogo        endp
  193. ────────────────────────────────────────────────────────────────────────────────
  194. convert         proc    near
  195.         xor     bx,bx
  196. @@two:          mov     cx,bp           ; ∙ lg to cx
  197. @@one:          xor     dx,dx
  198.         mov     dl,ds:[si]      ; ∙ read from srce to dl
  199.         shl     dx,4
  200.         shr     dl,4
  201.         add     dh,select
  202.         mov     ds:[di],dh
  203.         inc     di
  204.         add     dl,select
  205.         mov     ds:[di],dl
  206.         inc     di
  207.         inc     si
  208.         loop    @@one
  209.         dec     ax              ; ∙ dec
  210.         jnz     @@two
  211.         ret
  212. select          db      00
  213. convert         endp
  214. ────────────────────────────────────────────────────────────────────────────────
  215. ega2vga         proc    near
  216.         mov     si,offset logo
  217.         mov     di,offset vgalogo
  218.         mov     ax,85
  219.         mov     bp,256/2
  220.         call    convert
  221.         ret
  222. ega2vga         endp
  223. ────────────────────────────────────────────────────────────────────────────────
  224. checkkey        proc    near
  225.         cmp byte ptr keystroke,01
  226.         je      escape
  227.         jmp     no
  228. escape:         jmp     exit
  229. no:             ret
  230. checkkey        endp
  231. ────────────────────────────────────────────────────────────────────────────────
  232. int_key         proc    near
  233.         cli
  234.         push    ax
  235.         in      al,60h
  236.         cmp     al,01                   ; ∙ escape
  237.         je      put
  238.         mov     cs:keystroke,00
  239.         jmp     none                    ; ∙ none
  240. put:            mov     cs:keystroke,al
  241. none:           in      al,61h
  242.         mov     ah,al
  243.         or      al,80h
  244.         out     61h,al
  245.         sti
  246.         mov     al,20h
  247.         out     20h,al
  248.         pop     ax
  249.         iret
  250. keystroke       db      00
  251. int_key         endp
  252. ────────────────────────────────────────────────────────────────────────────────
  253. initkeyboard    proc    near
  254.         cli
  255.         push    fs
  256.         xor     dx,dx
  257.         mov     fs,dx
  258.         mov     eax,fs:[9*4]
  259.         mov     oldint9,eax
  260.         mov     ax,cs
  261.         shl     eax,16
  262.         mov     ax,offset int_key
  263.         mov     fs:[9*4],eax
  264.         sti
  265.         pop     fs
  266.         ret
  267. initkeyboard    endp
  268. ────────────────────────────────────────────────────────────────────────────────
  269. killkeyboard    proc near
  270.         cli
  271.         push    fs
  272.         xor     dx,dx
  273.         mov     fs,dx
  274.         mov     eax,oldint9
  275.         mov     fs:[9*4],eax
  276.         sti
  277.         pop     fs
  278.         ret
  279. killkeyboard    endp
  280. ────────────────────────────────────────────────────────────────────────────────
  281. timer           proc    near
  282.         push    ax
  283.         mov     al,20h
  284.         out     20h,al
  285.         inc     cs:counter
  286.         inc     cs:int_1ch
  287.         cmp     cs:int_1ch,22
  288.         jb      no_int_1ch
  289.         mov     cs:int_1ch,00
  290.         int    1ch
  291. no_int_1ch:     pop     ax
  292.         iret
  293. counter         dw      0
  294. int_1ch         db      0
  295. timer           endp
  296. ────────────────────────────────────────────────────────────────────────────────
  297. inittimer       proc    near
  298.         cli
  299.         push    gs
  300.         xor     dx,dx
  301.         mov     gs,dx
  302.         mov     eax,gs:[8*4]
  303.         mov     oldint8,eax
  304.         mov     ax,cs
  305.         shl     eax,16
  306.         mov     ax,offset timer
  307.         mov     dx,2841             ; ∙ 140 Hz double Screen Sync
  308.         mov     gs:[8*4],eax
  309.  
  310. out_it:         mov     al,036h                 ; ∙ out these things, they
  311.         out     43h,al                  ;   just remain a secret
  312.         mov     al,dl                   ;   for me...
  313.         out     40h,al
  314.         mov     al,dh
  315.         out     40h,al
  316.         sti
  317.         pop     gs
  318.         ret
  319. inittimer       endp
  320. ────────────────────────────────────────────────────────────────────────────────
  321. killtimer       proc near
  322.         push    gs
  323.         xor     dx,dx
  324.         mov     gs,dx
  325.         cli
  326.         mov     eax,oldint8
  327.         mov     gs:[8*4],eax
  328.         jmp     out_it
  329. killtimer       endp
  330. ────────────────────────────────────────────────────────────────────────────────
  331. initvideo    proc    near
  332.          call    zeropalette
  333.         mov    ax,13h
  334.         int    10h
  335.         call    zeropalette
  336.         
  337.         mov    dx,3c0h
  338.         mov    al,30h
  339.         out    dx,al
  340.         mov    al,01100001b
  341.         out    dx,al
  342.         mov    dx,3c4h            ; ∙ unchain mode!
  343.         mov    ax,604h
  344.         out    dx,ax
  345.         mov    dx,3d4h            ; ∙ four chain mode
  346.         mov    ax,14h
  347.         out    dx,ax
  348.         mov    ax,0e317h
  349.         out    dx,ax
  350.         mov    dx,3c4h            ; ∙ all planes
  351.         mov    ax,0f02h
  352.         out    dx,ax
  353.         mov    dx,3ceh            ; ∙ bitmasking
  354.         mov    ax,0ff08h
  355.         out    dx,ax
  356.  
  357.         push    @data
  358.         pop    ds
  359.         push    0a000h
  360.         pop    es
  361.         xor    di,di
  362.         xor    eax,eax
  363.         mov    cx,8000h/2
  364.         rep    stosd            ; ∙ clear screen
  365.         call    setpalette
  366.         ret
  367. initvideo    endp
  368. ────────────────────────────────────────────────────────────────────────────────
  369. killvideo    proc    near
  370.         mov     ah,12h              ; ∙ restore palette
  371.         mov     bl,31h
  372.         mov     al,00h
  373.         int     10h
  374.  
  375.         mov     ax,0003h        ; ∙ text mode!
  376.         int     10h
  377.         ret
  378. killvideo    endp
  379. ────────────────────────────────────────────────────────────────────────────────
  380. zeropalette    proc    near
  381.         mov     dx,03c8h                ; ∙ port PEL write mode
  382.         mov     al,00h                  ;   at register 00h
  383.         out     dx,al
  384.         xor    al,al
  385.         inc     dx                      ; ∙ port PEL data register
  386.         mov     cx,0100h*3
  387. @clear:        out    dx,al
  388.         loop    @clear
  389.         ret
  390. zeropalette    endp
  391. ────────────────────────────────────────────────────────────────────────────────
  392. setpalette     proc    near
  393.         mov     si,offset vgapalette
  394.         mov     dx,03c8h                ; ∙ port PEL write mode
  395.         mov     al,00h                  ;   at register 00h
  396.         out     dx,al
  397.         inc     dx                      ; ∙ port PEL data register
  398.         mov     cx,0100h*3
  399.         rep     outsb
  400.         ret                             ; ∙ vga color a 100h times
  401. setpalette    endp
  402. ────────────────────────────────────────────────────────────────────────────────
  403. doframing    proc    near
  404.         inc    framenumber
  405.         ret
  406. doframing    endp
  407. ────────────────────────────────────────────────────────────────────────────────
  408. main:        call    inittimer
  409.         call    initkeyboard
  410.         call    initvideo
  411.         call    ega2vga
  412.         call    putlogo
  413. plasma:     vsync
  414.         call    doframing
  415.         call    realplasma
  416.         call    checkkey
  417.         cmp    framenumber,1335
  418.         jmp    plasma
  419.  
  420. exit:       call    zeropalette
  421.         call    killvideo
  422.         call    killkeyboard
  423.         call    killtimer
  424.         mov    ax,4c00h
  425.         int    21h
  426. ────────────────────────────────────────────────────────────────────────────────
  427. .data
  428. oldint9         dd      ?
  429. oldint8         dd      ?
  430.  
  431. include        fire.pal
  432. include        f-scape.dat
  433. include        f-plasma.dat
  434. ────────────────────────────────────────────────────────────────────────────────
  435. udataseg
  436. initinitial    label     word
  437. lastvalue    dw    ?
  438. lastvalue2    dw    ?
  439.  
  440.         dw    160 dup (?)
  441. lastline    dw    320 dup (?)
  442.         dw    160 dup (?)
  443. endinitial     label    word
  444.  
  445. initzero       label    word
  446. vgalogo        db    256*85 dup (?)
  447.  
  448. thisline    dw    320 dup (?)
  449. slopes        dw    320 dup (?)
  450. drawline    dw    320 dup (?)
  451.  
  452. updatescr    dw    ?
  453.  
  454. framenumber    dd    ?
  455. hlimit        dw    ?
  456. lastslope    dw    ?
  457. endzero        label    word
  458. ────────────────────────────────────────────────────────────────────────────────
  459. end
  460.